import React, { Component } from 'react';
import {HomeListStyled} from 'styled/Home/HomeListStyled'
import {homeGetList} from 'api/homeApi'
class HomeList extends Component {
    constructor(props) {
        super(props);
        this.state={
            listData:[]
        }
    }
    componentDidMount() {
        homeGetList().then((ok)=>{
            console.log(ok)
            this.setState({
                listData:ok
            })
        })
    }
    
    
    render() {
        return (
            <HomeListStyled>
                <h2>精品优选</h2>
                {
                    this.state.listData.map((v,i)=>{
                        return (
                            <dl key={i}>
                                <dd>
                                    <img src={v.image} alt=""/>
                                </dd>
                                <dt>
                                    <h5>{v.goods_name}</h5>
                                    <p>{v.slogan}</p>
                                    <div>
                                        <h3>
                                        ￥<span>{v.price}</span>
                                            +<span>{v.audit}</span>积分
                                        </h3>
                                        <h4>
                                            <span>已售{v.buy_count}</span>
                                        </h4>
                                    </div>
                                    <i>放心购</i>
                                </dt>
                            </dl>
                        )
                    })
                }
            </HomeListStyled>
        );
    }
}

export default HomeList;